package com.quickask.entity;

import com.quickask.operate.data.RandomCode;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 * Created by NaSa on 2015/9/23.
 */
@Entity
@Table(name = "asknow_user_attention", schema = "", catalog = "quickask")
@org.hibernate.annotations.Cache(usage= CacheConcurrencyStrategy.READ_WRITE, region = "com.quickask.entity.AsknowUserAttentionEntity")
public class AsknowUserAttentionEntity implements Serializable {
    private int attentionId;  //关注id
    private Integer userId;  //用户id
    private Integer attentionUserId;  //被关注的用户id
    private Timestamp attentionTime;  //关注时间

    public void AsknowUserAttentionEntity() {
        this.attentionTime = new RandomCode().generateCurrentTimestamp();
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "attentionId", nullable = false, insertable = true, updatable = true)
    public int getAttentionId() {
        return attentionId;
    }

    public void setAttentionId(int attentionId) {
        this.attentionId = attentionId;
    }


    @Basic
    @Column(name = "userId", nullable = false, insertable = true, updatable = true)
    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "attentionUserId", nullable = true, insertable = true, updatable = true)
    public Integer getAttentionUserId() {
        return attentionUserId;
    }

    public void setAttentionUserId(Integer attentionUserId) {
        this.attentionUserId = attentionUserId;
    }

    @Basic
    @Column(name = "attentionTime", nullable = true, insertable = true, updatable = true)
    public Timestamp getAttentionTime() {
        return attentionTime;
    }

    public void setAttentionTime(Timestamp attentionTime) {
        this.attentionTime = attentionTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof AsknowUserAttentionEntity)) return false;

        AsknowUserAttentionEntity that = (AsknowUserAttentionEntity) o;

        if (attentionId != that.attentionId) return false;
        if (userId != null ? !userId.equals(that.userId) : that.userId != null) return false;
        if (attentionUserId != null ? !attentionUserId.equals(that.attentionUserId) : that.attentionUserId != null)
            return false;
        return !(attentionTime != null ? !attentionTime.equals(that.attentionTime) : that.attentionTime != null);

    }

    @Override
    public int hashCode() {
        int result = attentionId;
        result = 31 * result + (userId != null ? userId.hashCode() : 0);
        result = 31 * result + (attentionUserId != null ? attentionUserId.hashCode() : 0);
        result = 31 * result + (attentionTime != null ? attentionTime.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "AsknowUserAttentionEntity{" +
                "attentionId=" + attentionId +
                ", userId=" + userId +
                ", attentionUserId=" + attentionUserId +
                ", attentionTime=" + attentionTime +
                '}';
    }
}
